<template>
	<view>
		<!-- 自定义导航栏 -->
		<uni-nav-bar :statusBar="true" left-icon="arrowleft" rightText="发布" @click-left="back" @click-right="submit">
			<view class="title" @tap='changelook'>
				{{yinsi}}
				<view class="icon iconfont icon-xialazhankai"></view>
			</view>
		</uni-nav-bar>
		<!-- 多行输入框（文本域 ） -->
		<view class="uni-textarea">
			<textarea v-model="text" placeholder="说一些话吧" />
			</view>
			
			<!-- 多图片上传 -->
			<uplound-images @uplound='uplound'></uplound-images>
			
			<!-- popup 弹出层 -->
			<uni-popup ref="popup" :type="type" @change="change" >
				<view class="tanchuang">
					<view class="tanchuang-img">
						<image src="../../static/tanchuang.png" mode="widthFix"></image>
					</view>
					<view >1、涉及黄色，政治，广告及骚扰信息</view>
					<view >2、涉及人身攻击</view>
					<view >3、留联系方式，透露他人隐私</view>
					<view >一经核实将被封禁，情节严重者永久封禁</view>
					<button type="primary" @click.stop="hidePopup">朕知道了</button>
					
				</view>
			</uni-popup>
	</view>
</template>

<script>
	import uniIcons from '@/components/uni-icons/uni-icons.vue'
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	import uploundImages from '../../components/uplound-images/uplound-images.vue'
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	
	let changelook = ['所有人可见', '仅自己可见'];
	
	export default {
		components:{
			uniIcons,
			uniNavBar,
			uploundImages,
			uniPopup
		},
		data() {
			return {
				isget:false,
				yinsi:'所有人可见',
				text:'',
				imagelist:[],
				content: '顶部弹 popup',
				type: 'center',
			}
		},
		onBackPress() {
			if(!this.text && this.imagelist.length < 1){return;};
			if(!this.isget){
				this.baocun()
				return true;
			}
			
		},
		methods: {
			// 保存草稿
			baocun (){
				uni.showModal({
					content:'是否保存草稿?',
					cancelText:"不保存",
					confirmText:'保存',
					success:(res)=>{
						if(res.confirm){
							console.log("保存")
						}else {
							console.log('不保存')
						}
						this.isget = true
						uni.navigateBack({
							delta:1
						})
						
						}
				})
			},
			// 返回
			back(){
				uni.navigateBack()
			},
			// 发布
			submit(){},
			// 隐私
			changelook(){
				uni.showActionSheet({
				    itemList: changelook,
				    success: (res) => {
						this.yinsi = changelook[res.tapIndex]
				    }
				});
			},
			uplound(arr ){
				this.imagelist = arr
				console.log(this.imagelist)
			},
			change(e) {
				console.log(e.show)
			},
			hidePopup(){
				this.$refs['popup'].close(true)
			}
			
		}
	}
</script>

<style>
.title {
	display: flex;
	align-items: center;
	justify-content: center;
	margin:auto;
}
.uni-textarea {
	border:1upx solid #eee;
}
.example-body {
	padding: 10upx 30upx;
}
.tanchuang{
	text-align: left;
}	
.tanchuang-img {
	width:300upx;
	margin:0 auto;
}
.tanchuang-img image {
	width:100%;
}
.tanchuang button {
	background: #FFE22E;
	color:#171606;
}
</style>
